package com.bifang.module.file.gateway.controller;

import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.module.base.common.vo.org.OrgTreeVO;
import com.bifang.module.base.common.vo.tree.TreeRetVO;
import com.bifang.module.file.common.vo.*;
import com.bifang.module.file.core.biz.FileClassMIntegration;
import com.bifang.module.file.dao.model.FileClass;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "文件分类管理", description = "文件分类管理")
public class FileClassMController {
    @Autowired
    FileClassMIntegration fileClassMIntegration;

    @Operation(summary = "获取文件分类列表",description = "获取文件分类列表")
    @PostMapping(value = "/fileClassM0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileClassVO>> getFileInfoList(@RequestBody FileClassVO fileClassVO){
        return AppResponse.successData(fileClassMIntegration.getFileClassList(fileClassVO));
    }

    @Operation(summary = "新增文件分类信息",description = "新增文件分类信息")
    @PostMapping(value = "/fileClassM0002", produces = "application/json;charset=UTF-8")
    public AppResponse addFileClass(@RequestBody FileClassEditVO editVO){
        fileClassMIntegration.addFileClass(editVO);
        return AppResponse.success();
    }

    @Operation(summary = "修改文件分类信息",description = "修改文件分类信息")
    @PostMapping(value = "/fileClassM0003", produces = "application/json;charset=UTF-8")
    public AppResponse updateFileClass(@RequestBody FileClassEditVO editVO){
        fileClassMIntegration.updateFileClass(editVO);
        return AppResponse.success();
    }

    @Operation(summary = "删除文件分类信息",description = "删除文件分类信息")
    @PostMapping(value = "/fileClassM0004", produces = "application/json;charset=UTF-8")
    public AppResponse getFileInfoList(@RequestBody FileClassKeyVO keyVO){
        fileClassMIntegration.deleteFileClass(keyVO);
        return AppResponse.success();
    }

    @Operation(summary = "获取文件分类树",description = "获取文件分类树")
    @PostMapping(value = "/fileClassM0005", produces = "application/json;charset=UTF-8")
    public AppResponse<TreeRetVO> getFileClassTreeAllList(@RequestBody @Validated FileClassTreeVO vo) {
        return AppResponse.successData(fileClassMIntegration.getFileClassTreeAllList(vo));
    }

    @Operation(summary = "获取文件分类详情",description = "获取文件分类详情")
    @PostMapping(value = "/fileClassM0006", produces = "application/json;charset=UTF-8")
    public AppResponse<FileClassVO> getFileInfo(@RequestBody FileClassKeyVO keyVO){
        return AppResponse.successData(fileClassMIntegration.getFileInfo(keyVO));
    }
}
